<extend name="Public/layout"/>
<block name="head">
    <link rel="stylesheet" href="__PUBLIC__css/pushercenter.css?A=<php>echo time()</php>"">
    <script src="__PUBLIC__js/util.js"></script>
</block>
<block name="main">
    <!-- 新头部 -->
    <div class="news-header">
            <div class="list-item">
                <p>累计返现(元)</p>
                <p>
                      <if condition="$count_fx gt 0">{$count_fx}
                            <else/>
                            0.00
                        </if>

                </p>
                <p>昨日推广收益
                <span>
                    <if condition="$today_fx_count gt 0">{$today_fx_count}
                            <else/>
                            0.00
                        </if>

                </span>元</p>
            </div>
    </div>
    <!-- 我的投资人 -->
    <div class="list-item-info">
        <div class="item-info-title">我的投资人</div>
        <div class="item-info"><a href="/Home/Person/investor">推荐详情<span></span></a></div>
    </div>    
    <!--用户中心页头-->
    <!-- <div class="header">
        <div class="header-panel">
            <div class="header-panel-top">
                <div class="userinfo">
                    <div class="avatar" onclick="changeAvatar()">
                        <img id="uploadPreview" src="{$user_info.url_img}" alt="">
                        <input id="uploadImage" type="file" onchange="loadImageFile()">
                    </div>
                    <div class="info-wrapper">
                        <p class="name">{$user_info.nickname}</p>
                        <p class="user-number">{:hidtel($user_info[user_phone])}</p>
                    </div>
                </div>
                <div class="tool-box">
                    <div class="message" onclick="location.href='/Home/Person/notice'"></div>
                    <div class="setting" onclick="location.href='/Home/Person/setting'"></div>
                </div>
            </div>
            <div class="header-panel-bottom">
                <div class="total-return">
                    <p class="total-money">
                        <if condition="$count_fx gt 0">{$count_fx}
                            <else/>
                            0.00
                        </if>
                    </p>
                    <p>累计返现（元）</p>
                </div>
                <div class="yesterday-return">
                    <p class="yesterday-money">
                        <if condition="$today_fx_count gt 0">{$today_fx_count}
                            <else/>
                            0.00
                        </if>
                    </p>
                    <p>昨日推广收益（元）</p>
                </div>
            </div>
        </div>
    </div> -->
    <!--前往投资者中心按钮-->
    <!-- <div class="header-dropmenu">
        <div class="wrapper">
            <a href="{:U('Person/index')}">
                <div class="usercenter-icon-pusher"></div>
                <span>前往投资账户中心</span>
                <div class="arrow-wrapper">
                    <span class="arrow-right"></span>
                </div>
            </a>

            <if condition='$push eq 1'>
                <if condition='$user_info.auto_cash eq 0'>
                    <a href="javascript:" onclick="openAutoGetCash()">
                        <div class="icon-auto-get-cash"></div>
                        <span>自动提现</span>
                        <div class="text-wrapper">
                            <span>开启</span>
                        </div>
                    </a>
                    <else/>
                    <a href="javascript:" onclick="closeAutoGetCash()">
                        <div class="icon-auto-get-cash"></div>
                        <span>自动提现</span>
                        <div class="text-wrapper">
                            <span>关闭</span>
                        </div>
                    </a>
                </if>
            </if>


        </div>
    </div> -->
    <!--当日推广数据-->
    <div class="todays-datas">
        <div class="todays-datas-header">
            <h5>当日推广数据</h5>
        </div>
        <div class="todays-datas-body">
            <ul class="todays-datas-wrapper clearfix">
                <li>
                    <p class="data-desc">注册人数</p>
                    <p class="data"><em>{$push_user_count}</em>人</p>
                </li>
                <li>
                    <p class="data-desc">投资人数</p>
                    <p class="data"><em>{$today_tz_user_count}</em>人</p>
                </li>
                <li>
                    <p class="data-desc">CPA收益</p>
                    <p class="data"><em>{$cpa_today}</em>元</p>
                </li>
                <li>
                    <p class="data-desc">ROI收益</p>
                    <p class="data"><em>{$roi_today}</em>元</p>
                </li>
                <li>
                    <p class="data-desc">复投收益</p>
                    <p class="data"><em>{$cps_today}</em>元</p>
                </li>
            </ul>
        </div>
    </div>
    <!--用户余额信息-->
    <!-- <div class="user-account">
        <ul class="user-account-wrapper">


            <li class="user-account-item">

                <span class="item-name">可提现余额</span>
                <div class="arrow-wrapper">
                    <span class="arrow-right"></span>
                </div>
                <span class="total-cash-money">{$user_balance}</span>
                <if condition='$push eq 1'>
                    <a href="/Home/Person/cash/val/2"></a>
                    <else/>
                    <a href="javascript:" onclick="toBeFormerPusher()"></a>
                </if>
            </li>


            <li class="user-account-item">
                <span class="item-name">理财投顾专区</span>
                <div class="arrow-wrapper">
                    <span class="arrow-right"></span>
                </div>
                <span class="item-desc">合作平台返利规则</span>
                <a href="/Home/Recommend/push_list"></a>
            </li>
            <li class="user-account-item">
                <span class="item-name">交易明细</span>
                <div class="arrow-wrapper">
                    <span class="arrow-right"></span>
                </div>
                <span class="item-desc">账户交易所有明细</span>
                <a href="/Home/Person/trade_details"></a>
            </li>
            <li class="user-account-item">
                <span class="item-name">我的投资人</span>
                <div class="arrow-wrapper">
                    <span class="arrow-right"></span>
                </div>
                <span class="item-desc">被推荐人投资明细</span>
                <a href="/Home/Person/investor"></a>
            </li>
        </ul>
    </div> -->
    <!--我的合作平台-->
    <div class="my-platform">
        <div class="my-platform-header">
            <h5>邀请返利规则</h5>
        </div>
        <div class="my-platform-content">
            <ul class="my-platform-wrapper">
                <foreach name="hz_plat_info" item="v">
                    <li class="my-platform-item">
                        <div class="platform-wrapper">
                            <!--给下面的platform-item循环-->
                            <foreach name="v.platform_scheme" item="vv">
                                <div class="platform-item">
                                    <div class="item-header">
                                        <div class="plat-logo-wrapper">
                                            <img src="{$v.platform_info.pic}?x-oss-process=image/resize,w_110" alt="">
                                        </div>
                                        <div class="plat-return-type-wrapper">
                                            <p>{$v.platform_info.team_type}</p>
                                        </div>
                                        <div class="spread-btn-wrapper">
                                            <a class="spread-btn"
                                               href="/Home/Financial/event">立即邀请好友</a>
                                        </div>
                                    </div>
                                    <div class="item-content">
                                            <ul class="item-content-wrapper">
                                                <li>
                                                    <p><em>{$vv.user_award}</em>元</p>
                                                    <p class="item-desc">用户返利</p>
                                                </li>
                                                <li>
                                                    <p><em>{$vv.push_award}</em>元</p>
                                                    <p class="item-desc">邀请返利</p>
                                                </li>
                                                <li>
                                                    <p><em>{$vv.yields}</em></p>
                                                    <p class="item-desc">往期年化</p>
                                                </li>
                                            </ul>
                                            <ul class="item-content-wrapper">
                                                <li>
                                                    <p><em>{$vv.start_amount}</em>元</p>
                                                    <p class="item-desc">起投金额</p>
                                                </li>
                                                <li>
                                                    <p><em>{$vv.deadline}</em><if condition="$vv.deadline_unit eq 0">月<else/>天</if></p>
                                                    <p class="item-desc">投资期限</p>
                                                </li>
                                                <li>
                                                    <if condition="$v[platform_info][team_type] eq 'ROI'">
                                                        <p>多投多返</p>
                                                        <elseif condition="$v[platform_info][team_type] eq 'CPA'"/>
                                                        <p>首投返利</p>
                                                        <elseif condition="$v[platform_info][team_type] eq 'CPA+CPS'"/>
                                                        <p>首投+加息返利</p>
                                                    </if>

                                                    <p class="item-desc">返利类型</p>
                                                </li>
                                            </ul>
                                    </div>
                                </div>
                            </foreach>
                        </div>
                        <notempty name='v.platform_scheme'>
                        <div class="more-btn" onclick="viewMore(this)">更多邀请返利规则</div>
                        </notempty>
                    </li>
                </foreach>
                <foreach name="un_hz_plat" item="v">
                    <li class="my-platform-item">
                        <div class="item-header">
                            <div class="plat-logo-wrapper">
                                <img src="{$v.pic}?x-oss-process=image/resize,w_110" alt="">
                            </div>
                            <div class="plat-return-type-wrapper">
                                <p>{$v.team_type}</p>
                            </div>
                            <div class="spread-btn-wrapper">
                                <a class="spread-btn" href="javascript:" onclick="apply_platfrom({$v.id})">认领平台</a>
                            </div>
                        </div>
                        <div class="item-content">
                            <ul class="item-content-wrapper">
                                <li>
                                    <p><em>{$v.user_award}</em>元</p>
                                    <p class="item-desc">用户返利</p>
                                </li>
                                <li>
                                    <p><em>{$v.push_award}</em>元</p>
                                    <p class="item-desc">邀请返利</p>
                                </li>
                                <li>
                                    <p><em>{$v.yields}</em></p>
                                    <p class="item-desc">往期年化</p>
                                </li>
                            </ul>
                            <ul class="item-content-wrapper">
                                <li>
                                    <p><em>{$v.start_amount}</em>元</p>
                                    <p class="item-desc">起投金额</p>
                                </li>
                                <li>
                                    <p><em>{$v.deadline}</em></p>
                                    <p class="item-desc">投资期限</p>
                                </li>
                                <li>
                                    <if condition="$v[team_type] eq 'ROI'">
                                        <p>多投多返</p>
                                        <elseif condition="$v[team_type] eq 'CPA'"/>
                                        <p>首投返利</p>
                                        <elseif condition="$v[team_type] eq 'CPA+CPS'"/>
                                        <p>首投+加息返利</p>
                                    </if>

                                    <p class="item-desc">返利类型</p>
                                </li>
                            </ul>
                        </div>
                    </li>
                </foreach>

            </ul>
        </div>
    </div>


  <!--   <div class="aside" id="asideBar">
        <a href="{:U('Person/index')}">
            <span class="investcenter"></span>
            <span class="text">投资账户</span>
        </a>
    </div> -->

</block>
<block name="js">
    <script type="text/javascript">
        // 记录每个合作平台容器的高度
        var itemH = $(".platform-wrapper").height();


        function viewMore(obj) {
            if ($(obj).text() == "更多邀请返利规则") {
                $(obj).text("点击收起")
                $(obj).parent().children(".platform-wrapper").css("maxHeight", "100%")
            } else {
                $(obj).text("更多邀请返利规则")
                $(obj).parent().children(".platform-wrapper").css("maxHeight", itemH)
            }
        }

        $(window).bind("scrollstart", function () {
            $("#asideBar").css("transform", "translate3d(100%, 0, 0)")
        })

        $(window).bind("scrollstop", function () {
            $("#asideBar").css("transform", "translate3d(0, 0, 0)")
        })

        function openAutoGetCash() {
            // 开启自动提现弹框
            var h = '';
            h += '<div class="get-cash-layer">'
            h += '<div class="content-wrapper"><h3>开启自动提现</h3>'
            h += '<p class="text">开启自动提现后</p>'
            h += '<p class="text">每天17点将会自动将您账户</p>'
            h += '<p class="text">可提现余额提现到您绑定银行卡哦</p></div>'
            //        h += '<div class="btn-wrapper"><a href="#">我不需要</a>'
            //        h += '<a href="#">确认开启</a></div>'
            h += '</div>'

            layer.open({
                type: 1
                , content: h
                , btn: ['确认', '取消']
                , yes: function (index) {
                    auto_cash(1);
                }
            });
        }

        function closeAutoGetCash() {
            // 开启自动提现弹框
            var h = '';
            h += '<div class="get-cash-layer">'
            h += '<div class="content-wrapper"><h3>关闭自动提现</h3>'
            h += '<p class="text">关闭自动提现后</p>'
            h += '<p class="text">余额将不会每天自动提现</p>'
            h += '</div>'

            layer.open({
                type: 1
                , content: h
                , btn: ['确认', '取消']
                , yes: function (index) {
                    auto_cash(0);
                }
            });
        }

        function toBeFormerPusher() {
            layer.open({
                content: "您还不是正式投顾，请先完成见习任务！"
                , btn: ['前往', '取消']
                , yes: function (index) {
                    location.href = "/Home/Person/push_task"
                }
            });
        }

        function auto_cash(auto) {
            $.post('{:U("Person/auto_cash")}', {
                auto: auto,
            }, function (res) {
                if (res.err == 2) {

                    layer.closeAll()
                    layer.open({
                        content: "您还未绑定银行卡,请先绑定银行卡！"
                        , btn: ['前往', '取消']
                        , yes: function (index) {
                            location.href = "/Home/Person/bind_bank_card"
                        }
                    });

                } else {
                    layer.open({
                        content: res.msg
                        , skin: 'msg'
                        , time: 1
                        , end: function () {
                            location.reload()
                        }
                    });
                }
            })
        }

        function apply_platfrom(platform_id) {
            $.post('{:U("Recommend/apply_platfrom")}', {
                platform_id: platform_id
            }, function (res) {
                layer.open({
                    content: res.msg
                    , skin: 'msg'
                    , time: 1
                    , end: function () {
                        location.reload()
                    }
                });

            })
        }

        //    修改头像功能
        var oFReader = new FileReader();
        var rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i;


        oFReader.onload = function (oFREvent) {
            document.getElementById("uploadPreview").src = oFREvent.target.result;
            $.post('/Home/Person/change_head_pic',{
                file:oFREvent.target.result
            },function(res){
                if(res.errorCode==1) {
                    layer.open({
                        content: res.msg
                        , skin: 'msg'
                        , time: 1
                    });
                }
            })
        };



        function loadImageFile() {
            if (document.getElementById("uploadImage").files.length === 0) { return; }
            var oFile = document.getElementById("uploadImage").files[0];
            if (!rFilter.test(oFile.type)) { alert("You must select a valid image file!"); return; }
            oFReader.readAsDataURL(oFile);
        }

        function changeAvatar() {

//        底部对话框
            layer.open({
                content: ''
                ,className: 'avatar-layer'
                ,btn: ['取消', '从相册选择']
                ,skin: 'footer'
                ,no: function () {
                    $('#uploadImage').click()
                    layer.closeAll()
                }
                ,yes: function(index){
                    layer.close(index);
                }
            });
        }

    </script>
</block>